package com.dd.consul_consumer_feign;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import feign.Logger;


@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
@RestController
public class ConsulConsumerFeignApplication {
	
	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	@Bean
	public Logger.Level feignLoggerLevel() {
		return Logger.Level.FULL;
	}

	public static void main(String[] args) {
		SpringApplication.run(ConsulConsumerFeignApplication.class, args);
		System.out.println("服务已经启动");
	}
	
	
	@Autowired
    RestTemplate restTemplate;
    @GetMapping("/consumer")
    public String dc() {
        return restTemplate.getForObject("http://consul-provider/", String.class);
   //     return restTemplate.getForEntity("http://HELLO-SERVICE/hello", String.class).getBody();
    }
	
}
